perm filename BUG.SAI[CMU,AIL] blob sn#085160 filedate 1974-02-04 generic text, type T, neo UTF8
00100	BEGIN "BUG"
00200	REQUIRE "BAYSAI.SAI" SOURCE!FILE;
00300	REQUIRE "<>##" DELIMITERS;
00400	
00500	INTEGER EOF;
00600	REAL AMT,BAL;
00700	STRING S,DATE,NUM;
00800	
00900	DEFINE ICHAN=1,
01000		OCHAN=2,
01100		BRK=1,
01200		LINEBRK=3,
01300		DELETE=2,
01400		SPACES=<"                                        ">;
01500	
01600	SIMPLE PROCEDURE OUTP(STRING S; INTEGER W,A);
01700		BEGIN "OUTP"
01800		INTEGER T;
01900		T←LENGTH(S);
02000		OUT(OCHAN,SPACES[1 FOR W-T]&S[1 FOR W]&SPACES[1 FOR A]);
02100		END "OUTP";
02200	
02300	SETFORMAT(0,2);
02400	SETBREAK(BRK," ,"&TAB,NULL,"INS");
02500	SETBREAK(DELETE," ,"&TAB,NULL,"XNR");
02600	SETBREAK(LINEBRK,LF,CR,"IKNS");
02700	
02800	OPEN(ICHAN,"DSK",0,2,0,60,ZILCH,EOF);
02900	OPEN(OCHAN,"DSK",0,0,2,0,ZILCH,ZILCH);
03000	LOOKUP(ICHAN,"BUG.IN",ZILCH);
03100	ENTER(OCHAN,"BUG.TMP",ZILCH);
03200	
03300	OUTSTR("STARTING BALANCE: ");
03400	BAL←REALSCAN(SDUM←INCHWL,ZILCH);
03500	
03600	WHILE TRUE DO
03700	    BEGIN "LOOP"
03800		S←INPUT(ICHAN,LINEBRK);
03900		IF EOF THEN DONE;
04000		SZILCH←SCAN(S,DELETE,ZILCH);
04100		DATE←SCAN(S,BRK,ZILCH);
04200		SZILCH←SCAN(S,DELETE,ZILCH);
04300		NUM←SCAN(S,BRK,ZILCH);
04400		SZILCH←SCAN(S,DELETE,ZILCH);
04500		AMT←REALSCAN(S,ZILCH);
04600		OUTP(DATE,5,2);
04700		OUTP(NUM,5,2);
04800		OUTP(CVF(AMT),8,4);
04900		IF EQU(NUM,"DEP") OR EQU(NUM,"CR") THEN AMT←-AMT;
05000		BAL←BAL-AMT;
05100		OUTP(CVF(BAL),8,0); OUTP(CRLF,2,0);
05200	    END "LOOP";
05300	
05400	RELEASE(ICHAN);
05500	RELEASE(OCHAN);
05600	OUTSTR(CRLF&CVF(BAL)&CRLF&CRLF);
05700	
05800	END "BUG"